/**
 * 设置定点观测动画 
 * @param {Earth} options.earth 渲染容器
 * @param {string} options.positions 相机目标位置 [ lng, lat ]
 * @param {string} options.range 相机离地距离 单位米
 * @param {string} options.radians 相机旋转角度 [ x, y ]
 */

function earthLookAt (options) {
    let earthCamera = options.earth.camera
    let cesiumCamera = options.earth._viewer.camera
    let range = options.range || 250000
    let radians = options.radians || [ 0, -35 ]
    let positions = options.positions
    let radian = Math.PI / 180;


    earthCamera.flyTo(
        [positions[0] * radian, positions[1] * radian, 1], 
        range, 
        [ radians[0], radians[1] * radian, 0 ],
        1
    )

    setTimeout(() => {
        cesiumCamera.lookAt(
            new Cesium.Cartesian3.fromDegrees(positions[0], positions[1], 0), 
            new Cesium.HeadingPitchRange(
                Cesium.Math.toRadians(radians[0]), 
                Cesium.Math.toRadians(radians[1]), 
                range
            )
        )
    }, 1200)

}

export default earthLookAt